package com.example.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.example.bean.Banner;
import com.example.fruit.R;
import com.lidroid.xutils.BitmapUtils;
import com.lidroid.xutils.bitmap.BitmapDisplayConfig;
import com.lidroid.xutils.bitmap.callback.BitmapLoadCallBack;
import com.lidroid.xutils.bitmap.callback.BitmapLoadFrom;


import java.util.List;


public class HomeBannerAdapter extends AppBaseAdapter<Banner> {
    BitmapUtils bitmapUtils;


    public HomeBannerAdapter(Context context, List<Banner> list, BitmapUtils bitmapUtils) {
        super(context, list);
        this.bitmapUtils = bitmapUtils;

    }

    @Override
    public View getItemView(int position, View view, ViewGroup viewGroup) {
        ViewHolder vh;
        Log.i("info", "1116");
        if (view == null) {
            view = inflater.inflate(R.layout.item_banner, viewGroup, false);
            vh = new ViewHolder();
            vh.imageView = (ImageView) view.findViewById(R.id.img_itemId);
            view.setTag(vh);
        } else {
            vh = (ViewHolder) view.getTag();
        }
//        bitmapUtils.display(vh.imageView,list.get(position).getPhoto());
        Log.i("info", "1117");
//        bitmapUtils.display(vh.imageView, list.get(position).getPhoto(), new BitmapLoadCallBack<ImageView>() {
//
//
//            @Override
//            public void onLoading(ImageView container, String uri, BitmapDisplayConfig config, long total, long current) {
//                super.onLoading(container, uri, config, total, current);
//            }
//
//            @Override
//            public void onLoadCompleted(ImageView imageView, String s, Bitmap bitmap, BitmapDisplayConfig bitmapDisplayConfig, BitmapLoadFrom bitmapLoadFrom) {
//                imageView.setImageBitmap(bitmap);
//            }
//
//            @Override
//            public void onLoadFailed(ImageView imageView, String s, Drawable drawable) {
//                    imageView.setImageDrawable(drawable);
//            }
//        });
//


        return view;
    }

    private  class ViewHolder {
        ImageView imageView;

    }

}
